package game.editer;

import hx.events.MouseEvent;
import game.editer.ui.CommonButton;
import hx.display.HBox;

/**
 * 工具箱
 */
class ToolPanel extends HBox {
	override function onInit() {
		super.onInit();
		this.gap = 5;

		// 移动
		var moveBtn = new CommonButton("UIAtlas:move");
		this.addChild(moveBtn);
		moveBtn.addEventListener(MouseEvent.CLICK, onButtonClick);
		moveBtn.quad.data = moveBtn.upColor = 0x2a86bf;

		// 缩放
		var scaleBtn = new CommonButton("UIAtlas:scale");
		this.addChild(scaleBtn);
		scaleBtn.addEventListener(MouseEvent.CLICK, onButtonClick);

		// 旋转
		var rotateBtn = new CommonButton("UIAtlas:rotation");
		this.addChild(rotateBtn);
		rotateBtn.addEventListener(MouseEvent.CLICK, onButtonClick);
	}

	private function onButtonClick(e:MouseEvent):Void {
		for (object in this.children) {
			var button:CommonButton = cast object;
			button.upColor = e.target == button ? 0x2a86bf : 0x666666;
			button.quad.data = button.upColor;
		}
	}
}
